package com.managertrade.controller;

import com.managertrade.common.Result;
import com.managertrade.dto.vo.MenuVO;
import com.managertrade.service.impl.MenuService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
@CrossOrigin // 支持跨域请求
@RestController
@RequestMapping("/api/menu")
public class MenuController {

    @Resource
    private MenuService menuService;

    @GetMapping("/list")
    public Result<List<MenuVO>> getMenus(@RequestParam Long userId) {
        return Result.success(menuService.getMenuTreeByUserId(userId));
    }
    @GetMapping("/perms")
    public Result<List<String>> getButtonPerms(@RequestParam Long userId) {
        List<String> perms = menuService.getButtonPermsByUserId(userId);
        return Result.success(perms);
    }
}